package com.zuorenke.exception;

import com.zuorenke.help.StringUtils;

/**
 * @author Z.R.K
 * @description
 * @create 2019-05-20 14:11:13
 **/
public class MyRuntimeException extends RuntimeException {
		private static final long serialVersionUID = -2012236077094332457L;
		private String key;
		private Object[] args;
		
		public MyRuntimeException(String key) {
			super(buildPettyMessage(key));
			this.key = key;
		}
		
		public MyRuntimeException(Throwable cause) {
			super(cause);
		}
		
		public MyRuntimeException(String key, Object... args) {
			super(buildPettyMessage(key, args));
			this.key = key;
			this.args = args;
		}
		
		public MyRuntimeException(String key, Throwable cause, Object... args) {
			super(buildPettyMessage(key, args), cause);
			this.key = key;
			this.args = args;
		}
		
		public String getKey() {
			return this.key;
		}
		
		public Object[] getArgs() {
			return this.args;
		}
		
		private static String buildPettyMessage(String key, Object... args) {
			String message = key;
			if (StringUtils.isEmpty(message)) {
				message = key;
			}
			
			return message;
		}
	}
